// import { defineConfig } from "vite";
// import react from "@vitejs/plugin-react";

// // https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [react()],
// });

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [react()],
  define: {
    "process.env": {},
  },
  build: {
    lib: {
      // entry: path.resolve(__dirname, "src/MyComponent.jsx"),
      entry: "src/build.jsx",
      name: "MyComponent",
      // fileName: (format) => `my-component.${format}.js`,
      fileName: "index",
      formats: ["umd"],
    },
    rollupOptions: {
      // 确保外部化处理那些你不想打包进你的库的依赖
      external: ["react"],
      output: {
        format: "umd",
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
        globals: {
          react: "React",
        },
      },
    },
  },
});
